package com.xxx.server.controller;


import com.xxx.server.pojo.Position;
import com.xxx.server.service.IPositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
    职位管理
 *
 * @author cd
 * @since 2023-12-22
 */
@RestController
@RequestMapping("/system/basic/position/")
public class PositionController {
    @Autowired
    private IPositionService positionService;

    @GetMapping
    public List<Position> getPositions(){
        List<Position> list = positionService.list();
        return list;

    }
    @PostMapping
    public boolean addPosition(@RequestBody Position position ){
        boolean b = positionService.addPosition(position);
        return b;
    }
    @DeleteMapping("{positionId}")
    public boolean addPosition(@PathVariable int positionId){
        boolean b = positionService.removeById(positionId);
        return b;
    }
    @DeleteMapping()
    public boolean addPosition(@RequestBody List<Integer>  positionIds){
        boolean b = positionService.removeByIds(positionIds);
        return b;
    }
    @PutMapping()
    public boolean updatePosition(@RequestBody Position position){
        boolean b = positionService.updateById(position);
        return b;

    }


}
